package com.tedu.api;

import org.junit.Test;

public class homework {
    /*1.输出字符串"HelloJava"的字符串长度*/
    @Test
    public void testLength(){
        String str="HelloJava"; //9
        System.out.println(str.length());
    }
    /*2.输出"HelloJava"中o的位置*/
    @Test
    public void testSubString() {
        String url = "HelloJava";
    //    url = url.substring(4, 5);
        System.out.println("" + url);

        /*3.输出"HelloJava"中下标为5处开始第一次出现以"o"的位置*/
        url=url.substring(4);
        System.out.println(""+url);

        /*4.截取"HelloJava"中"Hello"并输出*/
        String url2 = "HelloJava";
        url2 = url2.substring(0,5);
        System.out.println(""+url2);

        /*5.截取"HelloJava"中"Java"并输出*/
        String url3 = "HelloJava";
        url3= url3.substring(5);
        System.out.println(""+url3);
    }

    /*6.将字符串" Hello "中两边的空白去掉后输出*/
    @Test
    public void testTrim(){
        String str=" Hello ";
        str=str.trim().toUpperCase();
        System.out.println("去掉空格"+str);
    }

    /*7.输出"HelloJava"中第6个字符"J"*/
    @Test
    public void testCharAt(){
        String str="HelloJava";
        char c=str.charAt(5);
        System.out.println("获取对应字符："+c);
    }

    /*8.将"HelloJava"转换为小写，然后转换为大写*/
    @Test
    public void testtoLowerCase(){
        String str=" HelloJava ";
        str=str.trim().toLowerCase();
        System.out.println("转换为小写"+str);
    }
    @Test
    public void testtoUpperCase(){
        String str=" HelloJava ";
        str=str.trim().toUpperCase();
        System.out.println("转换为大写"+str);
    }
}
